﻿using LdtJudge.DataEngine.Model.DataModel.CommonManageModel;
using LdtJudge.DataEngine.Model.DataModel.DynamicData;
using System;
using System.Collections.Generic;
using System.Text;



namespace LdtDataEngin.ModuleDetail.RegCommon.ReturnModeAnalysis
{
    ///<summary>
    /// 类名称  : ReturnAnalysis
    /// 功能    : 数据返回
    /// 更新人  : zsw 
    ///</summary> 
    public class ReturnAnalysis
    {
        public ReturnAnalysis() { }

        /// <summary>
        /// 数据返回方式（数据拼接）
        /// </summary>
        /// <param name="returnMode"></param>
        /// <param name="valuelist"></param>
        /// <returns></returns>
        public InteractiveModel ReturnData(ReturnMode returnMode, IDictionary<string, List<string>> valuelist, InteractiveModel interactiveModel)
        {
            interactiveModel.ModelDic = valuelist;
            interactiveModel.returnMode = returnMode;

            //进行返回数据拼接
            if (returnMode.RM_IsValue == 0)
            {
                string jsoinmode = returnMode.RM_JoinMode;
                if (jsoinmode == null)
                {
                    jsoinmode = "";
                }
                if (valuelist == null)
                {//如果进行处理结果集进行返回内容时，结果集为空，则直接返回空集合；
                    interactiveModel.ModelList = new List<string>();
                }
                else
                {
                    if (valuelist.ContainsKey("Ai"))
                    {
                        interactiveModel.ModelList.Add(string.Join(jsoinmode, valuelist["Ai"]));
                        
                    }
                    else
                    {
                        if (valuelist.ContainsKey("reg"))
                        {
                            interactiveModel.ModelList.Add(string.Join(jsoinmode, valuelist["reg"]));
                           
                        }
                    }
                }

            }
            else
            {
                if (valuelist != null)
                {
                    if (valuelist.ContainsKey("Ai"))
                    {
                        interactiveModel.ModelList = valuelist["Ai"];
                    }
                    else
                    {
                        if (valuelist.ContainsKey("reg"))
                        {
                            interactiveModel.ModelList = valuelist["reg"];
                        }
                    }
                }

            }
            return interactiveModel;
        }



    }
}
